package com.pro01.springlearning.mapper;

import com.pro01.springlearning.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    /**
     *  前面的是数据库字段，和数据库匹配，后面的是值，和实体类匹配
     */
    @Insert("insert into users(username, password, nickname) VALUES(#{username}, #{password}, #{nickname})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertUser(User user);

    @Select("select * from users WHERE username = #{username}")
    User findByUsername(String username);
}
